import { Warning, Link } from '@brillout/docpress'
import { ConfigSpec } from '../../components'

<ConfigSpec
  env="Vite (development & build-time)"
  global={null}
/>

Get the app's <Link href="/config">configurations</Link> that are available at config-time.

<Warning>It's a beta feature: expect breaking changes in any minor version update.</Warning>

> It only returns configurations that are available at config-time (i.e. at build- and dev-time). To get configurations at (production) runtime use <Link href="/globalContext#config">`globalContext.config`</Link> and <Link href="/globalContext#pages">`globalContext.pages`</Link> instead.

```ts
// vite.config.ts

import type { UserConfig, Plugin } from 'vite'
import { getVikeConfig } from 'vike/plugin'

export default {
  plugins: [myVitePlugin()]
} satisfies UserConfig

function myVitePlugin(): Plugin {
  return {
    name: 'myVitePlugin',
    configResolved(config) {
      const vike = getVikeConfig(config)
      console.log(vike.config.prerender)
      console.log(vike.config.baseAssets)
      console.log(vike.config.baseServer)

      console.log(vike.pages['/pages/index'].config)
      console.log(vike.pages['/pages/product'].route)

      // If you pre-render pages
      console.log(vike.prerenderContext.pageContexts)
      console.log(vike.prerenderContext.output)
    },
    config(config) {
      // Also available here
      const vike = getVikeConfig(config)
    }
  }
}
```

## See also

- <Link href="/config#files" />
- <Link href="/getGlobalContext" />
- <Link href="/globalContext#config">API > `globalContext.config`</Link>
- <Link href="/globalContext#pages">API > `globalContext.pages`</Link>
- <Link href="/globalContext#prerenderContext">API > `globalContext.prerenderContext`</Link>
- [Vite > Plugin API > `configResolved`](https://vite.dev/guide/api-plugin.html#configresolved)
- [Vite > Plugin API > `config`](https://vite.dev/guide/api-plugin.html#config)
